package com.zzh.leetCode.LeetCode_20211208;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author：zhangzhanheng
 * @createTime: 2021/12/8  11:26 上午
 * @desc:
 * @version: 1.0.0
 **/
public class Solution {

    public static double findMedianSortedArrays(int[] nums1, int[] nums2) {
        double d ;
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < nums1.length; i++) {
            a.add(nums1[i]);
        }
        for (int i = 0; i < nums2.length; i++) {
            a.add(nums2[i]);
        }
        Collections.sort(a);
        int size = a.size();
        if (size % 2 == 0) {
            int i = size / 2;
            int c = (size/2)-1;
            int i1 = a.get(i) + a.get(c);
            d =(double) i1/2;
        }else {
            d= a.get(size /2);
        }
        return d;
    }


    public static void main(String[] args) {
        int[] nums1 ={1,2};
        int[] nums2 ={3,4};
        System.out.println(findMedianSortedArrays(nums1, nums2));
    }



}
